﻿package plugin.bossChallenge
{
    import __AS3__.vec.*;
    import cmd.*;
    import com.core.*;
    import com.greensock.*;
    import com.sh.game.global.*;
    import consts.*;
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import morn.core.utils.*;
    import plugin.bossChallenge.ui.*;
    import plugin.component.view.*;
    import plugin.component.view.enum.*;
    import plugin.instance.*;
    import plugin.newvip.model.*;
    import pluginfw.nio.*;
    import uiresource.boss.*;
    import view.*;
    import view.message.*;
    import view.mornExtends.*;
    import view.uilt.*;

    public class BossChallengeUICtrl extends BossChallengeUI
    {
        private var _close:Function;
        private var cfgBossChallenge:Array;
        private var cfgMonster:Array;
        private var cfgInstance:Array;
        private var cfgMapList:Array;
        private var cfgItems:Object;
        private var tweenMax:TweenMax;
        private var curObj:Array;
        private var curBoss:Array;
        private var curBossId:int = 0;
        private var refreshList:Array;
        private var modelSprite:Sprite;
        private var bossModel:RoleShow;
        private var bossItem:BossItemCtrl;
        private var yewaiItem:YeWaiItemCtrl;
        private var yeWaiBOSS:Array;
        private var timeline:TweenMax;
        private var isClose:Array;
        private var arr:Array;
        private var btns:Vector.<Button>;
        private var curtime:int;
        private var timer:Timer;
        private var _timeID:uint = 0;

        public function BossChallengeUICtrl(param1:Function)
        {
            this.cfgBossChallenge = ConfigDictionary.data.bosschallenge;
            this.cfgMonster = ConfigDictionary.data.monster;
            this.cfgInstance = ConfigDictionary.data.instance;
            this.cfgMapList = ConfigDictionary.data.maplist;
            this.cfgItems = ConfigDictionary.data.item;
            this.refreshList = new Array();
            this.isClose = new Array();
            this.btns = new Vector.<Button>;
            this._close = param1;
            return;
        }// end function

        override protected function createChildren() : void
        {
            viewClassMap["uiresource.boss.BossItemUI"] = BossItemCtrl;
            viewClassMap["uiresource.boss.YeWaiBossListUI"] = YeWaiItemCtrl;
            loadUI("BossChallenge.xml");
            this.bossItem = BossItemUI as BossItemCtrl;
            this.yewaiItem = YeWaiBossListUI as YeWaiItemCtrl;
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            var _loc_1:* = Control.create(BossChallengeControl, this);
            ModelProxy.addObserver("bossChallenge", _loc_1);
            tab.selectHandler = new Handler(this.tabHandler);
            leftList.selectHandler = new Handler(this.listSelectHandler);
            enterBtn.addEventListener(MouseEvent.CLICK, this.enterHandelr);
            closeBtn.addEventListener(MouseEvent.CLICK, this.closeHandler);
            this.modelSprite = new Sprite();
            this.modelSprite.x = 410;
            this.modelSprite.y = 112;
            this.addChild(this.modelSprite);
            buyLabel.visible = false;
            crdlLabel.visible = false;
            leftList.renderHandler = new Handler(this.leftListRender);
            leftList.scrollBar.addEventListener(Event.CHANGE, this.onScrollBarChange);
            ModelProxy.change("guideitem", "guideid" + GuideType.GUIDE_BOSS1, tab.getChildAt(2));
            ModelProxy.change("guideitem", "guideid" + GuideType.GUIDE_BOSS3, tab.getChildAt(2));
            return;
        }// end function

        protected function onScrollBarChange(event:Event) : void
        {
            var _loc_3:Object = null;
            var _loc_2:* = leftList.selectedIndex;
            for each (_loc_3 in leftList.cells)
            {
                
                (_loc_3 as BossItemCtrl).btn.selected = false;
            }
            if (leftList.startIndex > _loc_2 || _loc_2 > leftList.startIndex + 7)
            {
                return;
            }
            (leftList.getCell(_loc_2) as BossItemCtrl).btn.selected = true;
            return;
        }// end function

        public function openRefresh(param1:Object) : void
        {
            tab.selectedIndex = int(param1);
            leftList.startIndex = 0;
            this.tabHandler(int(param1));
            var _loc_2:* = UserData.getOnlineData("guide");
            if (int(_loc_2[GuideType.GUIDE_BOSS0]) == 1 && GuideView.getInstance().checkIsDo(GuideType.GUIDE_BOSS12))
            {
                GuideView.getInstance().doGuide(GuideType.GUIDE_BOSS1);
            }
            else if (int(_loc_2[GuideType.GUIDE_BOSS2]) == 1 && GuideView.getInstance().checkIsDo(GuideType.GUIDE_BOSS4))
            {
                GuideView.getInstance().doGuide(GuideType.GUIDE_BOSS3);
            }
            return;
        }// end function

        private function tabHandler(param1:int) : void
        {
            ModelProxy.change("guide", "hide", GuideType.GUIDE_BOSS1);
            ModelProxy.change("guide", "hide", GuideType.GUIDE_BOSS3);
            if (param1 == 2)
            {
                enterBtn.visible = true;
                yewaiCon.visible = false;
                personCon.visible = true;
                label_time.visible = false;
            }
            else if (param1 == 1)
            {
                enterBtn.visible = false;
                leftList.startIndex = 0;
                yewaiCon.visible = true;
                personCon.visible = false;
                label_time.visible = true;
            }
            else
            {
                enterBtn.visible = false;
                leftList.startIndex = 0;
                yewaiCon.visible = true;
                personCon.visible = false;
                label_time.visible = false;
            }
            this.showLeftBtnList(param1);
            return;
        }// end function

        private function showLeftBtnList(param1:int) : void
        {
            var _loc_2:Object = null;
            var _loc_3:Output = null;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            if (this.curObj == null)
            {
                this.curObj = new Array();
            }
            else
            {
                while (this.curObj.length > 0)
                {
                    
                    this.curObj.pop();
                }
            }
            for each (_loc_2 in this.cfgBossChallenge)
            {
                
                if (param1 == 2)
                {
                    if (int(_loc_2.type) == 1)
                    {
                        this.curObj.push(_loc_2);
                    }
                    continue;
                }
                if (int(_loc_2.type) == 2 && _loc_2.listid)
                {
                    this.curObj.push(_loc_2);
                }
            }
            _loc_3 = new Output();
            _loc_4 = this.curObj.length;
            _loc_3.writeShort(_loc_4);
            while (_loc_5 < _loc_4)
            {
                
                _loc_3.writeVarInt(int(this.curObj[_loc_5].id), false);
                _loc_5++;
            }
            if (param1 == 0)
            {
                PluginManager.instance.sendToBufferServer("bossChallenge", CMDBossChallenge.AskYeWaiBoss, _loc_3);
            }
            else if (param1 == 2)
            {
                PluginManager.instance.sendToBufferServer("bossChallenge", CMDBossChallenge.AskPersonBoss, _loc_3);
            }
            else if (param1 == 1)
            {
                PluginManager.instance.sendToBufferServer("bossChallenge", CMDBossChallenge.AskYeWaiBoss, _loc_3);
            }
            return;
        }// end function

        public function showBossInfo(param1:int, param2:Array) : void
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_6:Array = null;
            var _loc_7:int = 0;
            var _loc_8:Array = null;
            var _loc_9:Object = null;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            var _loc_12:Array = null;
            var _loc_13:int = 0;
            var _loc_14:Array = null;
            var _loc_15:Object = null;
            var _loc_16:int = 0;
            var _loc_17:int = 0;
            var _loc_18:int = 0;
            var _loc_19:int = 0;
            var _loc_20:Array = null;
            var _loc_21:Object = null;
            var _loc_22:Object = null;
            if (!param2)
            {
                return;
            }
            this.clear();
            if (param1 == 1)
            {
                _loc_3 = 0;
                while (_loc_3 < param2.length)
                {
                    
                    if (param2[_loc_3].state == 1)
                    {
                        _loc_4 = int((ModelProxy.getValue("data", "servertime") + getTimer()) / 1000);
                        _loc_5 = int(param2[_loc_3].nextReliveTime);
                        if (_loc_5 <= _loc_4)
                        {
                            this.refreshList.push(param2[_loc_3]);
                        }
                    }
                    else if (param2[_loc_3].state == 2)
                    {
                        this.refreshList.push(param2[_loc_3]);
                    }
                    _loc_3++;
                }
            }
            if (tab.selectedIndex == 0)
            {
                if (this.refreshList.length > 0)
                {
                    this.yeWaiBOSS = this.refreshList;
                    _loc_6 = [];
                    _loc_7 = 0;
                    while (_loc_7 < this.refreshList.length)
                    {
                        
                        _loc_10 = this.cfgBossChallenge[this.refreshList[_loc_7].bossId].model;
                        _loc_11 = this.cfgBossChallenge[this.refreshList[_loc_7].bossId].paihang;
                        _loc_6[_loc_10 + "_" + _loc_11] = this.refreshList[_loc_7];
                        _loc_7++;
                    }
                    _loc_8 = [];
                    for each (_loc_9 in _loc_6)
                    {
                        
                        _loc_8.push(_loc_9);
                    }
                    _loc_8.sortOn("bossId", Array.NUMERIC);
                    this.curBoss = _loc_8;
                }
                else
                {
                    leftList.array = [];
                    ModelProxy.change("movetips", "error", "当前没有已刷新BOSS");
                    return;
                }
            }
            else if (tab.selectedIndex == 1)
            {
                this.yeWaiBOSS = param2;
                _loc_12 = [];
                _loc_13 = 0;
                while (_loc_13 < param2.length)
                {
                    
                    _loc_16 = this.cfgBossChallenge[param2[_loc_13].bossId].model;
                    _loc_17 = this.cfgBossChallenge[param2[_loc_13].bossId].paihang;
                    _loc_12[_loc_16 + "_" + _loc_17] = param2[_loc_13];
                    _loc_13++;
                }
                _loc_14 = [];
                for each (_loc_15 in _loc_12)
                {
                    
                    _loc_14.push(_loc_15);
                }
                _loc_14.sortOn("bossId", Array.NUMERIC);
                this.curBoss = _loc_14;
            }
            else
            {
                this.curBoss = param2;
            }
            leftList.array = this.curBoss;
            leftList.selectedIndex = 0;
            if (tab.selectedIndex == 2)
            {
                _loc_18 = 0;
                while (_loc_18 < leftList.array.length)
                {
                    
                    _loc_19 = int(this.cfgBossChallenge[int(leftList.array[_loc_18].bossId)].instanceId);
                    if (this.cfgInstance[_loc_19])
                    {
                        _loc_20 = (this.cfgInstance[_loc_19].limit_times as String).split(" ");
                        if (leftList.array[_loc_18].instanceEnterCount < _loc_20[1])
                        {
                            leftList.selectedIndex = _loc_18;
                            this.listSelectHandler(_loc_18);
                            _loc_21 = new Object();
                            _loc_21.index = _loc_18;
                            this.selectItem(_loc_21);
                            break;
                        }
                    }
                    _loc_18++;
                }
            }
            else
            {
                leftList.selectedIndex = 0;
                this.listSelectHandler(0);
                _loc_22 = new Object();
                _loc_22.index = 0;
                this.selectItem(_loc_22);
            }
            return;
        }// end function

        private function leftListRender(param1:Component, param2:int) : void
        {
            var _loc_3:Loader = null;
            var _loc_4:int = 0;
            var _loc_5:Array = null;
            if (param2 < leftList.length)
            {
                param1.dataSource.index = param2;
                (param1 as BossItemCtrl).data = param1.dataSource;
                if (tab.selectedIndex == 2)
                {
                    _loc_4 = int(this.cfgBossChallenge[int(leftList.array[param2].bossId)].instanceId);
                    if (this.cfgInstance[_loc_4])
                    {
                        _loc_5 = (this.cfgInstance[_loc_4].limit_times as String).split(" ");
                        if (leftList.array[param2].instanceEnterCount >= _loc_5[1])
                        {
                            (param1 as BossItemCtrl).countLable.color = 12985410;
                            this.isClose[param2] = 1;
                        }
                        else
                        {
                            (param1 as BossItemCtrl).countLable.color = 5485622;
                            this.isClose[param2] = 0;
                        }
                        (param1 as BossItemCtrl).countLable.text = leftList.array[param2].instanceEnterCount + "/" + _loc_5[1];
                    }
                    else
                    {
                        (param1 as BossItemCtrl).countLable.text = "";
                    }
                }
                else
                {
                    (param1 as BossItemCtrl).countLable.text = "";
                }
            }
            return;
        }// end function

        public function selectItem(param1:Object) : void
        {
            var _loc_3:Object = null;
            var _loc_2:* = param1.index;
            for each (_loc_3 in leftList.cells)
            {
                
                (_loc_3 as BossItemCtrl).btn.selected = false;
            }
            if (leftList.startIndex > _loc_2 || _loc_2 > leftList.startIndex + 9)
            {
                return;
            }
            (leftList.getCell(_loc_2) as BossItemCtrl).btn.selected = true;
            return;
        }// end function

        public function showFBJZCount() : void
        {
            var _loc_2:Object = null;
            var _loc_3:String = null;
            var _loc_4:Array = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:Array = null;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            var _loc_12:Array = null;
            var _loc_1:* = UserData.getUserData();
            if (!this.curBoss || this.curBoss.length == 0)
            {
                return;
            }
            if (this.curBoss && this.curBoss[leftList.selectedIndex])
            {
                this.curBossId = this.curBoss[leftList.selectedIndex].bossId;
                if (this.curBossId && this.cfgBossChallenge[this.curBossId])
                {
                    _loc_2 = this.cfgBossChallenge[this.curBossId];
                    if (_loc_2.level != 0)
                    {
                        _loc_3 = "";
                        _loc_4 = [];
                        _loc_5 = 0;
                        if ((_loc_2.level as String).search("&") > -1)
                        {
                            _loc_8 = (_loc_2.level as String).split("&");
                            _loc_9 = 0;
                            while (_loc_9 < _loc_8.length)
                            {
                                
                                _loc_4[_loc_9] = (_loc_8[_loc_9] as String).split("#");
                                _loc_9++;
                            }
                        }
                        else
                        {
                            _loc_5 = _loc_2.level;
                        }
                        _loc_6 = ModelProxy.getValue("data", "openday") + 1;
                        if (_loc_5)
                        {
                            if (_loc_5 > 999)
                            {
                                _loc_10 = _loc_5 / 1000;
                                if (_loc_1.rein >= _loc_10)
                                {
                                    _loc_3 = "<font color=\'#218a00\'>" + String(_loc_10) + "转</font>";
                                }
                                else
                                {
                                    _loc_3 = "<font color=\'#ff0000\'>" + String(_loc_10) + "转</font>";
                                }
                            }
                            else if (_loc_1.level >= _loc_5)
                            {
                                _loc_3 = "<font color=\'#218a00\'>" + String(_loc_5) + "级</font>";
                            }
                            else
                            {
                                _loc_3 = "<font color=\'#ff0000\'>" + String(_loc_5) + "级</font>";
                            }
                        }
                        else
                        {
                            _loc_11 = 0;
                            while (_loc_11 < _loc_4.length)
                            {
                                
                                if (_loc_6 == int(_loc_4[_loc_11][0]))
                                {
                                    if (_loc_1.level >= int(_loc_4[_loc_11][1]))
                                    {
                                        _loc_3 = "<font color=\'#218a00\'>" + _loc_4[_loc_11][1] + "级</font>";
                                    }
                                    else
                                    {
                                        _loc_3 = "<font color=\'#ff0000\'>" + _loc_4[_loc_11][1] + "级</font>";
                                    }
                                }
                                else if (_loc_6 < int(_loc_4[_loc_11][0]))
                                {
                                    if (_loc_4[(_loc_11 - 1)])
                                    {
                                        if (_loc_1.level >= int(_loc_4[(_loc_11 - 1)][1]))
                                        {
                                            _loc_3 = "<font color=\'#218a00\'>" + _loc_4[(_loc_11 - 1)][1] + "级</font>";
                                        }
                                        else
                                        {
                                            _loc_3 = "<font color=\'#ff0000\'>" + _loc_4[(_loc_11 - 1)][1] + "级</font>";
                                        }
                                    }
                                    break;
                                }
                                else if (_loc_6 > int(_loc_4[(_loc_4.length - 1)][0]))
                                {
                                    if (_loc_1.level >= int(_loc_4[(_loc_4.length - 1)][1]))
                                    {
                                        _loc_3 = "<font color=\'#218a00\'>" + _loc_4[(_loc_4.length - 1)][1] + "级</font>";
                                    }
                                    else
                                    {
                                        _loc_3 = "<font color=\'#ff0000\'>" + _loc_4[(_loc_4.length - 1)][1] + "级</font>";
                                    }
                                }
                                _loc_11++;
                            }
                        }
                        this.removeTween();
                        _loc_7 = ItemUilt.getAllCount(240202036);
                        if (_loc_2.item)
                        {
                            _loc_12 = (_loc_2.item as String).split(":");
                            if (_loc_7 >= int(_loc_12[1]))
                            {
                                _loc_3 = _loc_3 + ("  消耗道具：" + _loc_12[0] + "（<font color=\'#218a00\'>" + _loc_7 + "/" + _loc_12[1] + "</font>）");
                                getLabel.visible = false;
                            }
                            else
                            {
                                _loc_3 = _loc_3 + ("  消耗道具：" + _loc_12[0] + "（<font color=\'#ff0000\'>" + _loc_7 + "/" + _loc_12[1] + "</font>）");
                                getLabel.visible = true;
                                this.tweenMax = TweenMax.to(getLabel, 1, {glowFilter:{color:16763904, alpha:1, blurX:10, blurY:10}, yoyo:true, repeat:int.MAX_VALUE, alpha:1});
                                getLabel.clickHandler = new Handler(this.toGm);
                            }
                        }
                        else
                        {
                            getLabel.visible = false;
                        }
                        label_lv.text = _loc_3;
                    }
                }
            }
            return;
        }// end function

        private function listSelectHandler(param1:int) : void
        {
            var selectObj:Object;
            var items:Array;
            var num:int;
            var user:Object;
            var career:int;
            var img:int;
            var id2:int;
            var time:Array;
            var arr:Array;
            var arr3:Array;
            var arr4:Array;
            var o:Object;
            var dieBoss:Object;
            var marr3:Array;
            var mm:Object;
            var obj:Object;
            var obj2:Object;
            var obj1:Object;
            var index:* = param1;
            clearInterval(this._timeID);
            if (!this.curBoss)
            {
                return;
            }
            if (this.curBoss && this.curBoss.length == 0)
            {
                return;
            }
            if (this.curBoss && this.curBoss[index])
            {
                this.curBossId = this.curBoss[index].bossId;
            }
            if (this.cfgBossChallenge[this.curBossId])
            {
                selectObj = this.cfgBossChallenge[this.curBossId];
                items;
                label_zli.text = "推荐战力：" + selectObj.zhanli;
                num = this.cfgMonster[selectObj.monsterid].relive;
                label_time.text = "刷新时间：" + String(num / 60) + "分钟";
                if (this.bossModel == null)
                {
                    this.bossModel = new RoleShow(selectObj.model, 2, null, null, null);
                    this.bossModel.x = 103;
                    this.bossModel.y = int(selectObj.Yzuobiao);
                    this.modelSprite.addChild(this.bossModel);
                    this.bossModel.addEventListener(MouseEvent.CLICK, function () : void
            {
                bossModel.doAction(ActionType.ATTACK);
                return;
            }// end function
            );
                }
                else
                {
                    this.bossModel.y = int(selectObj.Yzuobiao);
                    this.bossModel.updateModel(selectObj.model);
                }
                user = UserData.getUserData();
                career = user.career;
                if (career == 1)
                {
                    items = (selectObj.dropitems1 as String).split("#");
                }
                else if (career == 2)
                {
                    items = (selectObj.dropitems2 as String).split("#");
                }
                else
                {
                    items = (selectObj.dropitems3 as String).split("#");
                }
                itemList.array = items;
                itemList.renderHandler = new Handler(this.itemListRender);
                itemList.x = itemPanel.width - itemList.array.length * 54 >> 1;
                img = int(selectObj.nameshow);
                if (img > 0)
                {
                    titleImg.visible = true;
                    titleImg.turl = Config.getUrl("assets/images/bossName/" + img + ".png");
                }
                else
                {
                    titleImg.visible = false;
                }
                this.clearTween();
                crdlLabel.visible = false;
                if (tab.selectedIndex == 2)
                {
                    if (selectObj)
                    {
                        this.showFBJZCount();
                        this.arr = (selectObj.map as String).split("#");
                        if (selectObj.map != "0")
                        {
                            if (this.cfgMapList[this.arr[0]])
                            {
                                label_weizhi.text = selectObj.mapname;
                            }
                        }
                        else if (selectObj.instanceId != "0")
                        {
                            if (this.cfgMapList[int(selectObj.instanceId)])
                            {
                                label_weizhi.text = this.cfgMapList[int(selectObj.instanceId)].name;
                            }
                        }
                        id2 = int(selectObj.instanceId);
                        if (this.cfgInstance[id2])
                        {
                            time = (this.cfgInstance[id2].limit_times as String).split(" ");
                            if (this.curBoss[index].instanceEnterCount >= time[1] && VipCheck.checkVipLevel() != 0)
                            {
                                buyLabel.visible = true;
                                this.timeline = TweenMax.to(buyLabel, 1, {glowFilter:{color:16763904, alpha:1, blurX:15, blurY:15, strength:2}, repeat:10000, yoyo:true});
                                buyLabel.clickHandler = new Handler(this.buyHandler, [this.curBoss[index]]);
                            }
                            else
                            {
                                buyLabel.visible = false;
                            }
                            if (this.curBoss[index].instanceEnterCount >= time[1])
                            {
                                crdlLabel.visible = true;
                            }
                        }
                    }
                }
                else
                {
                    YeWaiList.visible = true;
                    buyLabel.visible = false;
                    arr;
                    arr3;
                    arr4;
                    var _loc_3:int = 0;
                    var _loc_4:* = this.cfgBossChallenge;
                    while (_loc_4 in _loc_3)
                    {
                        
                        o = _loc_4[_loc_3];
                        if (this.cfgBossChallenge[int(this.curBoss[index].bossId)].model == o.model && this.cfgBossChallenge[int(this.curBoss[index].bossId)].paihang == o.paihang)
                        {
                            arr.push(o);
                        }
                    }
                    var _loc_3:int = 0;
                    var _loc_4:* = this.yeWaiBOSS;
                    while (_loc_4 in _loc_3)
                    {
                        
                        dieBoss = _loc_4[_loc_3];
                        var _loc_5:int = 0;
                        var _loc_6:* = arr;
                        while (_loc_6 in _loc_5)
                        {
                            
                            obj = _loc_6[_loc_5];
                            if (this.cfgBossChallenge[dieBoss.bossId].bossname == obj.bossname && this.cfgBossChallenge[dieBoss.bossId].paihang == obj.paihang)
                            {
                                arr4[dieBoss.bossId] = dieBoss;
                            }
                        }
                    }
                    marr3;
                    var _loc_3:int = 0;
                    var _loc_4:* = arr4;
                    while (_loc_4 in _loc_3)
                    {
                        
                        mm = _loc_4[_loc_3];
                        if (mm.state == 2)
                        {
                            obj1 = this.cfgBossChallenge[mm.bossId];
                            arr3.push(obj1);
                        }
                        obj2 = this.cfgBossChallenge[mm.bossId];
                        marr3.push(obj2);
                    }
                    if (tab.selectedIndex == 0)
                    {
                        YeWaiList.array = arr3;
                    }
                    else
                    {
                        YeWaiList.array = marr3;
                    }
                    YeWaiList.renderHandler = new Handler(this.yewaiListHandler);
                }
            }
            return;
        }// end function

        public function removeTween() : void
        {
            if (this.tweenMax)
            {
                this.tweenMax.kill();
                this.tweenMax = null;
                ObjectUtils.clearFilter(getLabel, GlowFilter);
            }
            return;
        }// end function

        private function toGm() : void
        {
            DialogMgr.instance.open(AppDialog.SC_BUY, {storeId:422});
            return;
        }// end function

        private function yewaiListHandler(param1:Component, param2:int) : void
        {
            if (param2 < YeWaiList.length)
            {
                param1.dataSource.index = param2;
                if (tab.selectedIndex == 0)
                {
                    (param1 as YeWaiItemCtrl).isChuan = 0;
                }
                else
                {
                    (param1 as YeWaiItemCtrl).isChuan = 1;
                }
                (param1 as YeWaiItemCtrl).data = param1.dataSource;
            }
            return;
        }// end function

        private function buyHandler(param1:Object) : void
        {
            var bossid:int;
            var money:int;
            var needMoney:int;
            var boss:* = param1;
            this.clearTween();
            bossid = boss.bossId;
            var mapid:* = int(this.cfgBossChallenge[this.curBoss[leftList.selectedIndex].bossId].instanceId);
            var arr:* = String(this.cfgInstance[int(this.cfgBossChallenge[bossid].instanceId)].canbuy).split("&");
            var result:* = ModelProxy.getValue("vip", "getvip");
            var myviplv:* = result.vipLevel;
            var canbuy:* = (arr[(myviplv - 1)] as String).split("#");
            var time:* = (this.cfgInstance[int(this.cfgBossChallenge[bossid].instanceId)].limit_times as String).split(" ");
            var tatalCount:* = int(canbuy[1]) + int(time[1]);
            if (boss.instanceEnterCount == tatalCount)
            {
                ModelProxy.change("movetips", "error", "今日购买次数已用完");
                return;
            }
            money = UserData.getBagData("money");
            needMoney = this.cfgInstance[int(this.cfgBossChallenge[bossid].instanceId)].price;
            Alert2.show("购买一次进入，需要花费" + String(needMoney) + "元宝", "", ["确定", "取消"], function (param1:int, param2:Object) : void
            {
                var _loc_3:int = 0;
                if (param1 == 0)
                {
                    if (money >= needMoney)
                    {
                        _loc_3 = int(cfgBossChallenge[bossid].instanceId);
                        PluginManager.instance.sendToServer("instance", CMDInstance.NpcInstance, {mapid:_loc_3, type:1});
                        close();
                    }
                    else
                    {
                        WarningManager.show(42);
                    }
                }
                return;
            }// end function
            );
            return;
        }// end function

        private function itemListRender(param1:Component, param2:int) : void
        {
            if (param2 < itemList.length)
            {
                (param1 as FlashItem).data = this.cfgItems[int(itemList.array[param2])];
            }
            return;
        }// end function

        private function enterHandelr(event:MouseEvent) : void
        {
            var _loc_2:String = null;
            var _loc_3:Array = null;
            var _loc_4:Object = null;
            var _loc_5:Array = null;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            var _loc_13:int = 0;
            var _loc_14:Array = null;
            var _loc_15:int = 0;
            var _loc_16:int = 0;
            var _loc_17:Array = null;
            if (tab.selectedIndex == 2)
            {
                this.removeTween();
                _loc_2 = "";
                _loc_3 = [];
                if (this.curBoss && this.curBoss[leftList.selectedIndex])
                {
                    _loc_4 = this.cfgBossChallenge[this.curBoss[leftList.selectedIndex].bossId];
                    if (_loc_4)
                    {
                        _loc_5 = [];
                        _loc_6 = 0;
                        _loc_7 = 0;
                        _loc_8 = 0;
                        if ((_loc_4.level as String).search("&") > -1)
                        {
                            _loc_14 = (_loc_4.level as String).split("&");
                            _loc_15 = 0;
                            while (_loc_15 < _loc_14.length)
                            {
                                
                                _loc_5[_loc_15] = (_loc_14[_loc_15] as String).split("#");
                                _loc_15++;
                            }
                        }
                        else
                        {
                            _loc_6 = _loc_4.level;
                        }
                        _loc_9 = ModelProxy.getValue("data", "openday") + 1;
                        if (_loc_6)
                        {
                            if (_loc_6 > 999)
                            {
                                _loc_8 = _loc_6 / 1000;
                            }
                        }
                        else
                        {
                            _loc_16 = 0;
                            while (_loc_16 < _loc_5.length)
                            {
                                
                                if (_loc_9 == int(_loc_5[_loc_16][0]))
                                {
                                    _loc_7 = _loc_5[_loc_16][1];
                                }
                                else if (_loc_9 < int(_loc_5[_loc_16][0]))
                                {
                                    if (_loc_5[(_loc_16 - 1)])
                                    {
                                        _loc_7 = _loc_5[(_loc_16 - 1)][1];
                                    }
                                    break;
                                }
                                else if (_loc_9 > int(_loc_5[(_loc_5.length - 1)][0]))
                                {
                                    _loc_7 = _loc_5[(_loc_5.length - 1)][1];
                                }
                                _loc_16++;
                            }
                        }
                        _loc_10 = UserData.getUserData("level");
                        _loc_11 = UserData.getUserData("rein");
                        if (_loc_8)
                        {
                            if (_loc_11 < _loc_8)
                            {
                                WarningManager.show(33, [_loc_8]);
                                return;
                            }
                        }
                        else if (_loc_6)
                        {
                            if (_loc_10 < _loc_6)
                            {
                                WarningManager.show(32, [_loc_6]);
                                return;
                            }
                        }
                        else if (_loc_7)
                        {
                            if (_loc_10 < _loc_7)
                            {
                                WarningManager.show(32, [_loc_7]);
                                return;
                            }
                        }
                        _loc_12 = ItemUilt.getAllCount(240202036);
                        if (_loc_4.item)
                        {
                            _loc_17 = (_loc_4.item as String).split(":");
                            if (_loc_12 < int(_loc_17[1]))
                            {
                                WarningManager.show(31, [_loc_17[0]]);
                                return;
                            }
                        }
                        _loc_13 = int(_loc_4.instanceId);
                        if (this.isClose[leftList.selectedIndex] == 0)
                        {
                            this._close();
                        }
                        else
                        {
                            WarningManager.show(45);
                            return;
                        }
                        PluginManager.instance.sendToServer("instance", CMDInstance.NpcInstance, {mapid:_loc_13, type:0});
                    }
                }
            }
            return;
        }// end function

        private function clear() : void
        {
            if (this.curBoss == null)
            {
                this.curBoss = new Array();
            }
            else
            {
                while (this.curBoss.length > 0)
                {
                    
                    this.curBoss.pop();
                }
            }
            if (this.refreshList == null)
            {
                this.refreshList = new Array();
            }
            else
            {
                while (this.refreshList.length > 0)
                {
                    
                    this.refreshList.pop();
                }
            }
            if (this.yeWaiBOSS == null)
            {
                this.yeWaiBOSS = new Array();
            }
            else
            {
                while (this.yeWaiBOSS.length > 0)
                {
                    
                    this.yeWaiBOSS.pop();
                }
            }
            return;
        }// end function

        private function clearTween() : void
        {
            if (this.timeline)
            {
                this.timeline.kill();
            }
            buyLabel.filters = [];
            return;
        }// end function

        private function closeHandler(event:MouseEvent) : void
        {
            this._close();
            return;
        }// end function

        public function close() : void
        {
            this._close();
            leftList.selectedIndex = 0;
            if (this.bossModel)
            {
                this.bossModel.destroy();
                this.bossModel = null;
            }
            this.clearTween();
            this.removeTween();
            return;
        }// end function

    }
}
